﻿using System;
using System.IO;
using System.Xml.Serialization;

namespace ZenWplExporter.Wpl
{
	/// <summary>
	/// Defines an WPL object
	/// </summary>
	[Serializable]
	[XmlRoot("smil")]
	public class Playlist
	{
		/// <summary>
		/// Gets or sets the body.
		/// </summary>
		/// <value>The body.</value>
		[XmlElement("body")]
		public Body Body { get; set; }

		/// <summary>
		/// Loads WPL from the specified path.
		/// </summary>
		/// <param name="path">The path.</param>
		/// <returns></returns>
		public static Playlist Load(string path)
		{
			if (path == null)
			{
				throw new ArgumentNullException("path");
			}

			var serializer = new XmlSerializer(typeof(Playlist));
			using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
			{
				return (Playlist)serializer.Deserialize(fileStream);
			}
		}
	}
}